home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #define MAXLEN 200
- #define SOURCE_MAX 80
- #define FIELD_MAX 200
- #define NIL '\0'
- #define TRUE 1
- #define FALSE 0
- #define END_OF_FILE 999
-
- FILE *inf, *outf;
- char filename[20],inf_name[20], outf_name[20];
- char in_text[MAXLEN];
- int num;
- void main(argc, argv)
- int argc;
- char **argv;
- {
- int i;
- char t;
-
- strcpy( inf_name, argv[1]);
- strcpy( outf_name, argv[2]);
- num=atoi(argv[3]);
-
- if ( (inf = fopen(inf_name,"r")) == NULL)
- {
- printf("Cannot open source data file %s.\n\n", inf_name);
- exit(1);
- }
-
- if ( (outf = fopen(outf_name,"w")) == NULL)
- {
- printf("Cannot open output file %s.\n\n", outf_name);
- exit(1);
- }
- while (!feof(inf)){
- for (i=0;i<num;i++){
- t=fgetc(inf);
- in_text[i]=t;
- }
- in_text[num]='\0';
- fprintf(outf,"%s\n",in_text);
- }
- fclose(inf);
- fclose(outf);
- printf ("\nEnd of loading program. Have a good day!!\n");
- return;
- }
-
- int rtrim_spaces(s)
- char s[];
- {
- int i=strlen(s);
- while (i>0 && s[i-1]==32) s[i-1]=s[i--];
- }